//
//  BaseTabBar.m
//  LocalGoods
//
//  Created by Feihong Ye on 2018/9/20.
//  Copyright © 2018年 Xiaodong Huang. All rights reserved.
//

#import "BaseTabBar.h"
//#import "MSCustomTabBar.h"
#import "BaseNav.h"

#import "HomeViewController.h"
#import "VideotapeViewController.h"
#import "MineViewController.h"

@interface BaseTabBar ()<UITabBarDelegate>
//@property (nonatomic, strong) MSCustomTabBar *mscTabBar;
@end

@implementation BaseTabBar

- (void)viewDidLoad {
    [super viewDidLoad];
    
}

// 按钮点击
- (void)clickCenterBtn {

    VideotapeViewController *videoVC = [[VideotapeViewController alloc] init];
    videoVC.modalPresentationStyle = UIModalPresentationOverCurrentContext;
    
    [self presentViewController:videoVC animated:YES completion:nil];
    
    
}

- (instancetype)init {
    if (self = [super init]) {
        
        /*
        // 利用KVO来使用自定义的tabBar
        self.mscTabBar = [[MSCustomTabBar alloc] init];
        [self.mscTabBar.centerBtn addTarget:self
                                     action:@selector(clickCenterBtn) forControlEvents:UIControlEventTouchUpInside];
        [self setValue:self.mscTabBar forKey:@"tabBar"];
         */
        [self buildUI];
    }
    
    return self;
}
/**构建视图*/
- (void)buildUI{
    
    // 首页
    HomeViewController *homeVC = [[HomeViewController alloc] init];
    BaseNav *nav = [[BaseNav alloc] initWithRootViewController:homeVC];
    homeVC.tabBarItem.title = @"home";
    homeVC.tabBarItem.image = [[UIImage imageNamed:@"投资1"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    homeVC.tabBarItem.selectedImage = [[UIImage imageNamed:@"投资2"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    [self addChildViewController:nav];

    // 我的
    MineViewController *mineVC = [[MineViewController alloc] init];
    mineVC.tabBarItem.title = @"mine";
    mineVC.tabBarItem.image = [[UIImage imageNamed:@"我的1"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    mineVC.tabBarItem.selectedImage = [[UIImage imageNamed:@"我的2"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    self.tabBar.tintColor = UIColor.blackColor;
    [self addChildViewController:[[BaseNav alloc] initWithRootViewController:mineVC]];
    
}


- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item {
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
